<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-8-19
 * Func   会员接口
 */
defined('IN_YuLin') || exit('NO PERMIT!');

if($a == 'create')	//	生成随机账号
{
	while(true)
	{
		$len = rand(8,12);
		$uname = strtolower(CreateCode('mix',$len));
		
		$tmp = $db->getrow('SELECT 1 FROM '.Table('user').' WHERE username = \''.$uname.'\'');
		!$tmp && exit($uname);
	}
	
	exit;
}
else if($a == 'check')	//	检测账号
{
	$username = NoBadStr($_GET['username']);
	(strlen($username) < 6 || strlen($username) > 16) && AjaxReturn(1,'账号只能为6-16位');
	
	$tmp = $db->getrow('SELECT 1 FROM '.Table('user').' WHERE username = \''.$username.'\'');
	$tmp && AjaxReturn(1,'账号已经被注册');
	
	AjaxReturn(0);
}